Get Forex
The Get Forex API allows the originating bank to validate the source currency provided in the message and sends the daily foreign exchange rate back for provided currency pairs.
The Get Forex method requests the originating bank to provide both the source and the target currency ISO codes in the request, with or without providing an effective date. When an effective date is provided, the Get Forex method response will contain the Visa B2B Connect foreign exchange rate for the requested processing day. Historical rates can also be returned by providing a past date as the effective date.
When using Get Forex, the source currency is intended to be the currency of the originator of the payment. The target currency will be the currency of the payment recipient.
Method: POST
{{URL}}/jsonrpc
Headers
Name | Value |
---|---|
Content-Type | application/json |
Example
Payload Parameters
- cURL
- C#
- Go
- NodeJs
curl --location --globoff '{{URL}}/jsonrpc' \
--header 'Content-Type: application/json' \
--data '{"id":"1","jsonrpc":"2.0","method":"VisaService.FXRate","params":{"api":{"credential":"Basic c3VwcG9ydCsxQG5ldHN5cy1pbmMuY29tOjM5ZDYxOGJkNTVmNzQ4ZGQ4ZWY4NWI5NWQxY2RlNDE5","signature":"{{signature}}"},"payload":{"sourceCurrencyAlphaCode":"AED","targetCurrencyAlphaCode":"EUR","effectiveDate":"2022-09-07"}}}'
var options = new RestClientOptions("{{URL}}/jsonrpc")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Post);
request.AddHeader("Content-Type", "application/json");
var body = @"{
" + "\n" +
@" ""id"": ""1"",
" + "\n" +
@" ""jsonrpc"": ""2.0"",
" + "\n" +
@" ""method"": ""VisaService.FXRate"",
" + "\n" +
@" ""params"": {
" + "\n" +
@" ""api"": {
" + "\n" +
@" ""credential"": ""Basic c3VwcG9ydCsxQG5ldHN5cy1pbmMuY29tOjM5ZDYxOGJkNTVmNzQ4ZGQ4ZWY4NWI5NWQxY2RlNDE5"",
" + "\n" +
@" ""signature"": ""{{signature}}""
" + "\n" +
@" },
" + "\n" +
@" ""payload"": {
" + "\n" +
@" ""sourceCurrencyAlphaCode"": ""AED"",
" + "\n" +
@" ""targetCurrencyAlphaCode"": ""EUR"",
" + "\n" +
@" ""effectiveDate"": ""2022-09-07""
" + "\n" +
@" }
" + "\n" +
@" }
" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "{{URL}}/jsonrpc"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"id": "1",`+"
"+`
"jsonrpc": "2.0",`+"
"+`
"method": "VisaService.FXRate",`+"
"+`
"params": {`+"
"+`
"api": {`+"
"+`
"credential": "Basic c3VwcG9ydCsxQG5ldHN5cy1pbmMuY29tOjM5ZDYxOGJkNTVmNzQ4ZGQ4ZWY4NWI5NWQxY2RlNDE5",`+"
"+`
"signature": "{{signature}}"`+"
"+`
},`+"
"+`
"payload": {`+"
"+`
"sourceCurrencyAlphaCode": "AED",`+"
"+`
"targetCurrencyAlphaCode": "EUR",`+"
"+`
"effectiveDate": "2022-09-07"`+"
"+`
}`+"
"+`
}`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': '{{URL}}',
'path': '/jsonrpc',
'headers': {
'Content-Type': 'application/json'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = JSON.stringify({
"id": "1",
"jsonrpc": "2.0",
"method": "VisaService.FXRate",
"params": {
"api": {
"credential": "Basic c3VwcG9ydCsxQG5ldHN5cy1pbmMuY29tOjM5ZDYxOGJkNTVmNzQ4ZGQ4ZWY4NWI5NWQxY2RlNDE5",
"signature": "{{signature}}"
},
"payload": {
"sourceCurrencyAlphaCode": "AED",
"targetCurrencyAlphaCode": "EUR",
"effectiveDate": "2022-09-07"
}
}
});
req.write(postData);
req.end();
Body
{
"id": "1",
"jsonrpc": "2.0",
"method": "VisaService.FXRate",
"params": {
"api": {
"credential": "Basic c3VwcG9ydCsxQG5ldHN5cy1pbmMuY29tOjM5ZDYxOGJkNTVmNzQ4ZGQ4ZWY4NWI5NWQxY2RlNDE5",
"signature": "{{signature}}"
},
"payload": {
"sourceCurrencyAlphaCode": "AED",
"targetCurrencyAlphaCode": "EUR",
"effectiveDate": "2022-09-07"
}
}
}
Response: 201
Response Parameters
{
"jsonrpc": "2.0",
"result": {
"effectiveConversionRate": 0.2465009176,
"targetCurrency": "EUR",
"sourceCurrency": "AED",
"rateExpiry": "2023-05-26T11:59:59Z",
"rateId": "349e91acdb02491194776702c21187bd",
"effectiveConversionRateWithMarkup": 0.2465009176
},
"id": "1"
}